<template>
  <view>
    <view class="home_tap">
      <view class="home_tap_title">
        <view class="title_inner">
          <uni-segmented-control
            :current="current"
            :values="items.map(v=>v.title)"
            @clickItem="onClickItem"
            style-type="text"
            active-color="#4cd964"
          ></uni-segmented-control>
        </view>
        <view class="iconfont icon-soushuo"></view>
      </view>
      <view class="home_tap_content content">
        <view v-show="current === 0">
          <home-recommend></home-recommend>
        </view>
        <view v-show="current === 1">
          <home-category></home-category>
        </view>
        <view v-show="current === 2">
          <home-new></home-new>
        </view>
        <view v-show="current === 3">
          <home-album></home-album>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { homeAlbum } from "./home-album/index";
import { homeNew } from "./home-new/index";
import { homeRecommend } from "./home-recommend/index";
import { homeCategory } from "./home-category/index";
import { uniSegmentedControl } from "@dcloudio/uni-ui";
export default {
  components: {
    homeAlbum,
    homeNew,
    homeRecommend,
    homeCategory,
    uniSegmentedControl
  },
  data() {
    return {
      items: [
        { title: "推荐" },
        { title: "分类" },
        { title: "最新" },
        { title: "专辑" }
      ],
      current:0
    };
  },
  methods: {
    onClickItem(e) {
      if (this.current !== e.currentIndex) {
        this.current = e.currentIndex;
      }
    }
  },
};
</script>

<style lang="scss" scoped>
.home_tap{
 
  .home_tap_title{
     position: relative;
     border-bottom:1px solid #cccccc;
    .title_inner{
      width:60%;
      margin:0 auto;
    }
    .iconfont{
    position:absolute;
    top:50%;
    transform: translateY(-50%);
    right:5%;
    }
  }
  .home_tap_content {}
}
</style>